﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assets.Script.gamecore.action
{
    public class ActionManager
    {
        List<BaseAction> _actionList = new List<BaseAction>();

        public void UpdateLogic()
        {
            //更新所有动作
            for(int i = 0;i < _actionList.Count;i++)
            {
                if(_actionList[i].Enable)
                {
                    _actionList[i].UpdateLogic();
                }
            }
            //移除已经无效的
            for(int i = 0;i < _actionList.Count;i++)
            {
                if(!_actionList[i].Enable)
                {
                    _actionList.Remove(_actionList[i]);
                }
            }
        }

        public void AddAction(BaseAction action)
        {
            _actionList.Add(action);
        }

        public void RemoveAction(BaseAction action)
        {
            if(_actionList.Count == 0)
            {
                return;
            }
            _actionList.Remove(action);
        }


    }
}